<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
	</head>
	<body>
		<div id="example-1">
			<button v-on:click="counter += 1">Add 1</button>
			<button v-on:click="add">方法</button>
			<button v-on:click="add2(2)">参数</button>
			<a href="https://www.atstudy.com" v-on:click.prevent="add3(6,$event)">事件对象</a>
			<button @click.once="add4">触发一次</button>
			<p>{{ counter }}</p>
		</div>
		<script type="text/javascript">
			var example1 = new Vue({
				el: '#example-1',
				data: {
					counter: 0
				},
				methods: {
					/* add: function() {
						this.counter += 1;
					} */
					add() {
						this.counter += 1;
					},
					add2(n) {
						this.counter += n;
					},
					add3(n, e) {
						// e.preventDefault(); //阻止默认行为
						this.counter += n;
					},
					add4() {
						this.counter += 1;
					}
				}
			})
		</script>
	</body>
</html>
